package com.ainiyar.springweb.pojo.entity;

import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.List;

/**************************************
 * File Name : Admin
 * Created with : IntelliJ IDEA.
 * Author : 艾尼亚尔·毛拉吾提
 * QQ : 524155792  WeChat : ainiyar0124
 * Created Time : 2024/2/4  12:26
 * Desc :管理员实体类
 ***************************************/
@Data
@Table("sw_admin")
public class Admin implements Serializable, UserDetails {
    @Id(keyType = KeyType.Auto)
    private Long id;
    private String account;
    private String password;
    private String nickName;
    private String phone;
    private String eMail;
    private int sex;
    private String avatar;
    private Integer isSupper;//是否超级管理员
    private Integer roleId;//角色id
    private int type = 0;
    private String lastIp;
    private boolean isAccountNonExpired = true;     //账号是否过期(1:未过期,0:已过期)
    private boolean isAccountNonLocked = true;    //账号是否被锁定(1:未锁定,0:已锁定)
    private boolean isCredentialsNonExpired = true;     //密码是否已过期 (1:未过期,0:已过期)
    @Column(onInsertValue = "NOW()")
    private LocalDateTime createTime;
    @Column(onUpdateValue = "NOW()")
    private LocalDateTime updateTime;
    //权限列表
    @Column(ignore = true)
    Collection<?extends GrantedAuthority> authorities;
    //用户查询权限列表
    @Column(ignore = true)
    private List<Menu> permissionList;
    @Override
    public String getUsername() {
        return getAccount();
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}

